home *** CD-ROM | disk | FTP | other *** search
- Path: ns.mad.servicom.es!news
- From: ores@mad.servicom.es (Orestes Sanchez)
- Newsgroups: comp.lang.c++
- Subject: Re: Casting
- Date: Mon, 25 Mar 1996 22:29:59 GMT
- Organization: SERVICOM
- Message-ID: <4j77ba$i5e@ns.mad.servicom.es>
- References: <3146DB9C.4022@cs.bham.ac.uk> <4idvk3$pc1@sam.inforamp.net>
- NNTP-Posting-Host: ppp_mad_61.inf.servicom.es
- X-Newsreader: Forte Free Agent 1.0.82
-
- rmorin@inforamp.net (Randy Charles Morin) wrote:
-
- >In article <3146DB9C.4022@cs.bham.ac.uk>,
- > Matthew G Butler <M.G.Butler-MSCSE95@cs.bham.ac.uk> wrote:
- >>Can anyone tell me how to cast from one data type to another? What is
- >>the syntax? Do I have to cast explicitly or can I stick a casting
- >>function into my ADT and let the sprites sort it out.
-
-
- >I hope this is enough
- >Agrivar
-
- Well, it is ok.
- There is another way: casting operator.
- Say you want to convert an X object to an int.
-
- class X
- {
- public:
- [...]
- operator int();
- }
-
- X x;
- int i;
- i= (int)x;
-
- I recomend you to read the "The Annotated C++ Reference Manual" or
- some other book from Bjarne Stroupstrup. If you are a beginner try
- better "The C++ language" book. The ARM is hard to digest.
-
- Orestes
-
-
-